package org.xtext.ic.dsl;

import com.google.common.base.Objects;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.common.types.JvmDeclaredType;
import org.eclipse.xtext.xbase.lib.StringExtensions;
import org.xtext.ic.dsl.generator.HibernateAnnotationsExtensions;
import org.xtext.ic.dsl.icDsl.Attribute;
import org.xtext.ic.dsl.icDsl.CreateDAO;
import org.xtext.ic.dsl.icDsl.Entity;
import org.xtext.ic.dsl.icDsl.Flags;
import org.xtext.ic.dsl.icDsl.Layer;
import org.xtext.ic.dsl.icDsl.Model;
import org.xtext.ic.dsl.icDsl.PackagePrefix;
import org.xtext.ic.dsl.icDsl.Type;
import org.xtext.ic.dsl.icDsl.TypeDef;

@SuppressWarnings("all")
public class IcDslExtensions extends HibernateAnnotationsExtensions {
  public String packageName(final PackagePrefix pp, final Object o) {
    String _xifexpression = null;
    String _name = pp.getName();
    boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_name);
    if (_isNullOrEmpty) {
      String _layerName = this.layerName(o);
      _xifexpression = _layerName;
    } else {
      String _xifexpression_1 = null;
      if ((o instanceof String)) {
        String _name_1 = pp.getName();
        String _concatPath = this.concatPath(_name_1, ((String) o));
        _xifexpression_1 = _concatPath;
      } else {
        String _name_2 = pp.getName();
        String _plus = (_name_2 + ".");
        String _layerName_1 = this.layerName(o);
        String _plus_1 = (_plus + _layerName_1);
        _xifexpression_1 = _plus_1;
      }
      _xifexpression = _xifexpression_1;
    }
    return _xifexpression;
  }
  
  public String layerName(final Object o) {
    String _switchResult = null;
    boolean _matched = false;
    if (!_matched) {
      if (o instanceof Layer) {
        final Layer _layer = (Layer)o;
        _matched=true;
        EObject _eContainer = _layer.eContainer();
        String _layerName = this.layerName(_eContainer);
        String _name = _layer.getName();
        String _concatPath = this.concatPath(_layerName, _name);
        _switchResult = _concatPath;
      }
    }
    if (!_matched) {
      if (o instanceof EObject) {
        final EObject _eObject = (EObject)o;
        _matched=true;
        EObject _eContainer = _eObject.eContainer();
        String _layerName = this.layerName(_eContainer);
        _switchResult = _layerName;
      }
    }
    if (!_matched) {
      if (o instanceof JvmDeclaredType) {
        final JvmDeclaredType _jvmDeclaredType = (JvmDeclaredType)o;
        _matched=true;
        String _layerName = this.layerName(_jvmDeclaredType);
        _switchResult = _layerName;
      }
    }
    if (!_matched) {
      _switchResult = null;
    }
    return _switchResult;
  }
  
  public String concatPath(final String prefix, final String suffix) {
    String _xifexpression = null;
    boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(prefix);
    if (_isNullOrEmpty) {
      _xifexpression = suffix;
    } else {
      String _plus = (prefix + ".");
      String _plus_1 = (_plus + suffix);
      _xifexpression = _plus_1;
    }
    return _xifexpression;
  }
  
  public CharSequence typeDeclaration(final Attribute a) {
    StringConcatenation _builder = new StringConcatenation();
    {
      boolean _isMany = a.isMany();
      if (_isMany) {
        _builder.append("List<");
        Type _type = a.getType();
        String _name = _type.getName();
        _builder.append(_name, "");
        _builder.append(">");
      } else {
        Type _type_1 = a.getType();
        String _name_1 = _type_1.getName();
        _builder.append(_name_1, "");
      }
    }
    return _builder;
  }
  
  public CharSequence variable(final Attribute a) {
    StringConcatenation _builder = new StringConcatenation();
    CharSequence _typeDeclaration = this.typeDeclaration(a);
    _builder.append(_typeDeclaration, "");
    _builder.append(" ");
    String _name = a.getName();
    _builder.append(_name, "");
    return _builder;
  }
  
  public CharSequence packageHeader(final Model m, final EObject e) {
    StringConcatenation _builder = new StringConcatenation();
    {
      if ((e instanceof CreateDAO)) {
        _builder.append("package ");
        PackagePrefix _package = m.getPackage();
        Layer _daolayer = ((CreateDAO) e).getDaolayer();
        String _packageName = this.packageName(_package, _daolayer);
        _builder.append(_packageName, "");
        _builder.append(";");
        _builder.newLineIfNotEmpty();
      } else {
        EObject _eContainer = e.eContainer();
        if ((_eContainer instanceof Layer)) {
          _builder.append("package ");
          PackagePrefix _package_1 = m.getPackage();
          String _packageName_1 = this.packageName(_package_1, e);
          _builder.append(_packageName_1, "");
          _builder.append(";");
          _builder.newLineIfNotEmpty();
        } else {
          {
            PackagePrefix _package_2 = m.getPackage();
            String _name = _package_2.getName();
            boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_name);
            boolean _not = (!_isNullOrEmpty);
            if (_not) {
              _builder.append("package ");
              PackagePrefix _package_3 = m.getPackage();
              String _name_1 = _package_3.getName();
              _builder.append(_name_1, "");
              _builder.append(";");
              _builder.newLineIfNotEmpty();
            }
          }
        }
      }
    }
    return _builder;
  }
  
  public CharSequence importEntity(final Model m, final Entity e) {
    StringConcatenation _builder = new StringConcatenation();
    {
      EObject _eContainer = e.eContainer();
      if ((_eContainer instanceof Layer)) {
        _builder.append("import ");
        PackagePrefix _package = m.getPackage();
        String _packageName = this.packageName(_package, e);
        _builder.append(_packageName, "");
        _builder.append(".");
        String _name = e.getName();
        _builder.append(_name, "");
        _builder.append(";");
        _builder.newLineIfNotEmpty();
      } else {
        {
          PackagePrefix _package_1 = m.getPackage();
          String _name_1 = _package_1.getName();
          boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_name_1);
          boolean _not = (!_isNullOrEmpty);
          if (_not) {
            _builder.append("import ");
            PackagePrefix _package_2 = m.getPackage();
            String _name_2 = _package_2.getName();
            _builder.append(_name_2, "");
            _builder.append(".");
            String _name_3 = e.getName();
            _builder.append(_name_3, "");
            _builder.append(";");
            _builder.newLineIfNotEmpty();
          } else {
            _builder.append("import ");
            String _name_4 = e.getName();
            _builder.append(_name_4, "");
            _builder.append(";");
            _builder.newLineIfNotEmpty();
          }
        }
      }
    }
    return _builder;
  }
  
  private boolean existsImportOneToOne = false;
  
  private boolean existsImportOneToMany = false;
  
  private boolean existsImportManyToOne = false;
  
  private boolean existsImportManyToMany = false;
  
  private boolean existsImportEntityAnnotation = false;
  
  private boolean existsImportId = false;
  
  private boolean existsImportGeneratedValue = false;
  
  private boolean existsImportTemporal = false;
  
  private boolean existsImportInheritance = false;
  
  private boolean existsImportTable = false;
  
  private boolean existsImportColumn = false;
  
  private boolean existsImportJoinColumn = false;
  
  private boolean existsImportPrimaryKeyJoinColumn = false;
  
  private boolean existsImportJoinTable = false;
  
  private boolean existsImportCascade = false;
  
  public String importAnnotations(final Entity e) {
    String _xblockexpression = null;
    {
      String annotationImports = "";
      EList<Attribute> _attributes = e.getAttributes();
      for (final Attribute a : _attributes) {
        Type _type = a.getType();
        final Type _switchValue = _type;
        boolean _matched = false;
        if (!_matched) {
          if (_switchValue instanceof Entity) {
            final Entity _entity = (Entity)_switchValue;
            _matched=true;
            String _importEntityAnnotations = this.importEntityAnnotations(a, e);
            String _plus = (annotationImports + _importEntityAnnotations);
            annotationImports = _plus;
          }
        }
        if (!_matched) {
          if (_switchValue instanceof TypeDef) {
            final TypeDef _typeDef = (TypeDef)_switchValue;
            _matched=true;
            String _typeDefImport = this.typeDefImport(a);
            String _plus = (annotationImports + _typeDefImport);
            annotationImports = _plus;
          }
        }
      }
      Entity _superEntity = e.getSuperEntity();
      boolean _notEquals = (!Objects.equal(_superEntity, null));
      if (_notEquals) {
        String _importEntityAnnotations = this.importEntityAnnotations(e);
        String _plus = (annotationImports + _importEntityAnnotations);
        annotationImports = _plus;
      }
      this.existsImportOneToOne = false;
      this.existsImportOneToMany = false;
      this.existsImportManyToOne = false;
      this.existsImportManyToMany = false;
      this.existsImportEntityAnnotation = false;
      this.existsImportId = false;
      this.existsImportGeneratedValue = false;
      this.existsImportTemporal = false;
      this.existsImportInheritance = false;
      this.existsImportTable = false;
      this.existsImportColumn = false;
      this.existsImportJoinColumn = false;
      this.existsImportPrimaryKeyJoinColumn = false;
      this.existsImportJoinTable = false;
      this.existsImportCascade = false;
      _xblockexpression = (annotationImports);
    }
    return _xblockexpression;
  }
  
  public String typeDefImport(final Attribute a) {
    String _xblockexpression = null;
    {
      String annotationImports = "";
      boolean _not = (!this.existsImportColumn);
      if (_not) {
        CharSequence _importColumn = this.importColumn();
        String _plus = (annotationImports + _importColumn);
        String _property = System.getProperty("line.separator");
        String _plus_1 = (_plus + _property);
        annotationImports = _plus_1;
        this.existsImportColumn = true;
      }
      Flags _flags = a.getFlags();
      boolean _notEquals = (!Objects.equal(_flags, null));
      if (_notEquals) {
        Flags _flags_1 = a.getFlags();
        boolean _isId = _flags_1.isId();
        if (_isId) {
          boolean _not_1 = (!this.existsImportId);
          if (_not_1) {
            CharSequence _importId = this.importId();
            String _plus_2 = (annotationImports + _importId);
            String _property_1 = System.getProperty("line.separator");
            String _plus_3 = (_plus_2 + _property_1);
            annotationImports = _plus_3;
            this.existsImportId = true;
          }
          Flags _flags_2 = a.getFlags();
          boolean _isAutoid = _flags_2.isAutoid();
          if (_isAutoid) {
            boolean _not_2 = (!this.existsImportGeneratedValue);
            if (_not_2) {
              CharSequence _importGeneratedValue = this.importGeneratedValue();
              String _plus_4 = (annotationImports + _importGeneratedValue);
              String _property_2 = System.getProperty("line.separator");
              String _plus_5 = (_plus_4 + _property_2);
              annotationImports = _plus_5;
              this.existsImportGeneratedValue = true;
            }
          }
        }
      }
      Type _type = a.getType();
      String _mappedType = ((TypeDef) _type).getMappedType();
      boolean _notEquals_1 = (!Objects.equal(_mappedType, null));
      if (_notEquals_1) {
        Type _type_1 = a.getType();
        String _mappedType_1 = ((TypeDef) _type_1).getMappedType();
        boolean _equals = Objects.equal(_mappedType_1, "java.util.Date");
        if (_equals) {
          boolean _not_3 = (!this.existsImportTemporal);
          if (_not_3) {
            CharSequence _importTemporal = this.importTemporal();
            String _plus_6 = (annotationImports + _importTemporal);
            String _property_3 = System.getProperty("line.separator");
            String _plus_7 = (_plus_6 + _property_3);
            annotationImports = _plus_7;
            this.existsImportTemporal = true;
          }
        }
      }
      _xblockexpression = (annotationImports);
    }
    return _xblockexpression;
  }
  
  public String importEntityAnnotations(final Attribute a, final Entity e) {
    String _xblockexpression = null;
    {
      String annotationImports = "";
      boolean _not = (!this.existsImportEntityAnnotation);
      if (_not) {
        CharSequence _importEntityAnnotation = this.importEntityAnnotation();
        String _plus = (annotationImports + _importEntityAnnotation);
        String _property = System.getProperty("line.separator");
        String _plus_1 = (_plus + _property);
        annotationImports = _plus_1;
        this.existsImportEntityAnnotation = true;
      }
      boolean _not_1 = (!this.existsImportTable);
      if (_not_1) {
        CharSequence _importTable = this.importTable();
        String _plus_2 = (annotationImports + _importTable);
        String _property_1 = System.getProperty("line.separator");
        String _plus_3 = (_plus_2 + _property_1);
        annotationImports = _plus_3;
        this.existsImportTable = true;
      }
      String _importInheritanceAnnotations = this.importInheritanceAnnotations(e);
      String _plus_4 = (annotationImports + _importInheritanceAnnotations);
      String _importRelationshipAnnotations = this.importRelationshipAnnotations(a);
      String _plus_5 = (_plus_4 + _importRelationshipAnnotations);
      annotationImports = _plus_5;
      _xblockexpression = (annotationImports);
    }
    return _xblockexpression;
  }
  
  public String importEntityAnnotations(final Entity e) {
    String _xblockexpression = null;
    {
      String annotationImports = "";
      boolean _not = (!this.existsImportEntityAnnotation);
      if (_not) {
        CharSequence _importEntityAnnotation = this.importEntityAnnotation();
        String _plus = (annotationImports + _importEntityAnnotation);
        String _property = System.getProperty("line.separator");
        String _plus_1 = (_plus + _property);
        annotationImports = _plus_1;
        this.existsImportEntityAnnotation = true;
      }
      boolean _not_1 = (!this.existsImportTable);
      if (_not_1) {
        CharSequence _importTable = this.importTable();
        String _plus_2 = (annotationImports + _importTable);
        String _property_1 = System.getProperty("line.separator");
        String _plus_3 = (_plus_2 + _property_1);
        annotationImports = _plus_3;
        this.existsImportTable = true;
      }
      String _importInheritanceAnnotations = this.importInheritanceAnnotations(e);
      String _plus_4 = (annotationImports + _importInheritanceAnnotations);
      annotationImports = _plus_4;
      _xblockexpression = (annotationImports);
    }
    return _xblockexpression;
  }
  
  public String importInheritanceAnnotations(final Entity e) {
    String _xblockexpression = null;
    {
      String annotationImports = "";
      Entity _superEntity = e.getSuperEntity();
      boolean _notEquals = (!Objects.equal(_superEntity, null));
      if (_notEquals) {
        Entity _superEntity_1 = e.getSuperEntity();
        EList<Attribute> _attributes = _superEntity_1.getAttributes();
        for (final Attribute att : _attributes) {
          Flags _flags = att.getFlags();
          boolean _notEquals_1 = (!Objects.equal(_flags, null));
          if (_notEquals_1) {
            Flags _flags_1 = att.getFlags();
            boolean _isId = _flags_1.isId();
            if (_isId) {
              boolean _not = (!this.existsImportPrimaryKeyJoinColumn);
              if (_not) {
                CharSequence _importPrimaryKeyJoinColumn = this.importPrimaryKeyJoinColumn();
                String _plus = (annotationImports + _importPrimaryKeyJoinColumn);
                String _property = System.getProperty("line.separator");
                String _plus_1 = (_plus + _property);
                annotationImports = _plus_1;
                this.existsImportPrimaryKeyJoinColumn = true;
              }
            }
          }
        }
      }
      EObject _eContainer = e.eContainer();
      if ((_eContainer instanceof Model)) {
        EObject _eContainer_1 = e.eContainer();
        EList<Type> otherEntities = ((Model) _eContainer_1).getTypes();
        for (final Type ent : otherEntities) {
          if ((ent instanceof Entity)) {
            Entity _superEntity_2 = ((Entity) ent).getSuperEntity();
            String _name = _superEntity_2.getName();
            String _name_1 = e.getName();
            boolean _equals = Objects.equal(_name, _name_1);
            if (_equals) {
              boolean _not_1 = (!this.existsImportInheritance);
              if (_not_1) {
                CharSequence _importInheritance = this.importInheritance();
                String _plus_2 = (annotationImports + _importInheritance);
                String _property_1 = System.getProperty("line.separator");
                String _plus_3 = (_plus_2 + _property_1);
                annotationImports = _plus_3;
                this.existsImportInheritance = true;
              }
            }
          }
        }
      } else {
        EObject _eContainer_2 = e.eContainer();
        if ((_eContainer_2 instanceof Layer)) {
          EObject _eContainer_3 = e.eContainer();
          EList<Type> otherEntities_1 = ((Layer) _eContainer_3).getTypes();
          for (final Type ent_1 : otherEntities_1) {
            if ((ent_1 instanceof Entity)) {
              Entity entCast = ((Entity) ent_1);
              Entity _superEntity_3 = entCast.getSuperEntity();
              boolean _notEquals_2 = (!Objects.equal(_superEntity_3, null));
              if (_notEquals_2) {
                Entity _superEntity_4 = entCast.getSuperEntity();
                String _name_2 = _superEntity_4.getName();
                String _name_3 = e.getName();
                boolean _equals_1 = Objects.equal(_name_2, _name_3);
                if (_equals_1) {
                  boolean _not_2 = (!this.existsImportInheritance);
                  if (_not_2) {
                    CharSequence _importInheritance_1 = this.importInheritance();
                    String _plus_4 = (annotationImports + _importInheritance_1);
                    String _property_2 = System.getProperty("line.separator");
                    String _plus_5 = (_plus_4 + _property_2);
                    annotationImports = _plus_5;
                    this.existsImportInheritance = true;
                  }
                }
              }
            }
          }
        }
      }
      _xblockexpression = (annotationImports);
    }
    return _xblockexpression;
  }
  
  public String importRelationshipAnnotations(final Attribute a) {
    String _xblockexpression = null;
    {
      String annotationImports = "";
      Type _type = a.getType();
      if ((_type instanceof Entity)) {
        boolean _isOne = a.isOne();
        if (_isOne) {
          EObject _eContainer = a.eContainer();
          if ((_eContainer instanceof Entity)) {
            EObject _eContainer_1 = a.eContainer();
            Entity entidade = ((Entity) _eContainer_1);
            Type _type_1 = a.getType();
            EList<Attribute> _attributes = ((Entity) _type_1).getAttributes();
            for (final Attribute e : _attributes) {
              Type _type_2 = e.getType();
              String _name = _type_2.getName();
              String _name_1 = entidade.getName();
              boolean _equals = Objects.equal(_name, _name_1);
              if (_equals) {
                boolean _isOne_1 = e.isOne();
                if (_isOne_1) {
                  EObject _eContainer_2 = entidade.eContainer();
                  if ((_eContainer_2 instanceof Layer)) {
                    EObject _eContainer_3 = entidade.eContainer();
                    Layer layerCast = ((Layer) _eContainer_3);
                    CreateDAO _createdao = layerCast.getCreatedao();
                    boolean _notEquals = (!Objects.equal(_createdao, null));
                    if (_notEquals) {
                      CreateDAO _createdao_1 = layerCast.getCreatedao();
                      Entity _firstEntity = _createdao_1.getFirstEntity();
                      String _name_2 = _firstEntity.getName();
                      String _name_3 = entidade.getName();
                      boolean _equals_1 = Objects.equal(_name_2, _name_3);
                      if (_equals_1) {
                        boolean _not = (!this.existsImportOneToOne);
                        if (_not) {
                          CharSequence _importOneToOne = this.importOneToOne();
                          String _plus = (annotationImports + _importOneToOne);
                          String _property = System.getProperty("line.separator");
                          String _plus_1 = (_plus + _property);
                          annotationImports = _plus_1;
                          this.existsImportOneToOne = true;
                        }
                        boolean _not_1 = (!this.existsImportCascade);
                        if (_not_1) {
                          CharSequence _importCascade = this.importCascade();
                          String _plus_2 = (annotationImports + _importCascade);
                          String _property_1 = System.getProperty("line.separator");
                          String _plus_3 = (_plus_2 + _property_1);
                          annotationImports = _plus_3;
                          this.existsImportCascade = true;
                        }
                      } else {
                        CreateDAO _createdao_2 = layerCast.getCreatedao();
                        Entity _firstEntity_1 = _createdao_2.getFirstEntity();
                        String _name_4 = _firstEntity_1.getName();
                        Type _type_3 = a.getType();
                        String _name_5 = _type_3.getName();
                        boolean _equals_2 = Objects.equal(_name_4, _name_5);
                        if (_equals_2) {
                          boolean _not_2 = (!this.existsImportOneToOne);
                          if (_not_2) {
                            CharSequence _importOneToOne_1 = this.importOneToOne();
                            String _plus_4 = (annotationImports + _importOneToOne_1);
                            String _property_2 = System.getProperty("line.separator");
                            String _plus_5 = (_plus_4 + _property_2);
                            annotationImports = _plus_5;
                            this.existsImportOneToOne = true;
                          }
                          boolean _not_3 = (!this.existsImportPrimaryKeyJoinColumn);
                          if (_not_3) {
                            CharSequence _importPrimaryKeyJoinColumn = this.importPrimaryKeyJoinColumn();
                            String _plus_6 = (annotationImports + _importPrimaryKeyJoinColumn);
                            String _property_3 = System.getProperty("line.separator");
                            String _plus_7 = (_plus_6 + _property_3);
                            annotationImports = _plus_7;
                            this.existsImportPrimaryKeyJoinColumn = true;
                          }
                        } else {
                          CreateDAO _createdao_3 = layerCast.getCreatedao();
                          EList<Entity> _entities = _createdao_3.getEntities();
                          for (final Entity ent : _entities) {
                            String _name_6 = ent.getName();
                            String _name_7 = entidade.getName();
                            boolean _equals_3 = Objects.equal(_name_6, _name_7);
                            if (_equals_3) {
                              boolean _not_4 = (!this.existsImportOneToOne);
                              if (_not_4) {
                                CharSequence _importOneToOne_2 = this.importOneToOne();
                                String _plus_8 = (annotationImports + _importOneToOne_2);
                                String _property_4 = System.getProperty("line.separator");
                                String _plus_9 = (_plus_8 + _property_4);
                                annotationImports = _plus_9;
                                this.existsImportOneToOne = true;
                              }
                              boolean _not_5 = (!this.existsImportCascade);
                              if (_not_5) {
                                CharSequence _importCascade_1 = this.importCascade();
                                String _plus_10 = (annotationImports + _importCascade_1);
                                String _property_5 = System.getProperty("line.separator");
                                String _plus_11 = (_plus_10 + _property_5);
                                annotationImports = _plus_11;
                                this.existsImportCascade = true;
                              }
                            } else {
                              String _name_8 = ent.getName();
                              Type _type_4 = a.getType();
                              String _name_9 = _type_4.getName();
                              boolean _equals_4 = Objects.equal(_name_8, _name_9);
                              if (_equals_4) {
                                boolean _not_6 = (!this.existsImportOneToOne);
                                if (_not_6) {
                                  CharSequence _importOneToOne_3 = this.importOneToOne();
                                  String _plus_12 = (annotationImports + _importOneToOne_3);
                                  String _property_6 = System.getProperty("line.separator");
                                  String _plus_13 = (_plus_12 + _property_6);
                                  annotationImports = _plus_13;
                                  this.existsImportOneToOne = true;
                                }
                                boolean _not_7 = (!this.existsImportPrimaryKeyJoinColumn);
                                if (_not_7) {
                                  CharSequence _importPrimaryKeyJoinColumn_1 = this.importPrimaryKeyJoinColumn();
                                  String _plus_14 = (annotationImports + _importPrimaryKeyJoinColumn_1);
                                  String _property_7 = System.getProperty("line.separator");
                                  String _plus_15 = (_plus_14 + _property_7);
                                  annotationImports = _plus_15;
                                  this.existsImportPrimaryKeyJoinColumn = true;
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  } else {
                    EObject _eContainer_4 = entidade.eContainer();
                    if ((_eContainer_4 instanceof Model)) {
                      EObject _eContainer_5 = entidade.eContainer();
                      Model modelCast = ((Model) _eContainer_5);
                      CreateDAO _createdao_4 = modelCast.getCreatedao();
                      boolean _notEquals_1 = (!Objects.equal(_createdao_4, null));
                      if (_notEquals_1) {
                        CreateDAO _createdao_5 = modelCast.getCreatedao();
                        Entity _firstEntity_2 = _createdao_5.getFirstEntity();
                        String _name_10 = _firstEntity_2.getName();
                        String _name_11 = entidade.getName();
                        boolean _equals_5 = Objects.equal(_name_10, _name_11);
                        if (_equals_5) {
                          boolean _not_8 = (!this.existsImportOneToOne);
                          if (_not_8) {
                            CharSequence _importOneToOne_4 = this.importOneToOne();
                            String _plus_16 = (annotationImports + _importOneToOne_4);
                            String _property_8 = System.getProperty("line.separator");
                            String _plus_17 = (_plus_16 + _property_8);
                            annotationImports = _plus_17;
                            this.existsImportOneToOne = true;
                          }
                          boolean _not_9 = (!this.existsImportCascade);
                          if (_not_9) {
                            CharSequence _importCascade_2 = this.importCascade();
                            String _plus_18 = (annotationImports + _importCascade_2);
                            String _property_9 = System.getProperty("line.separator");
                            String _plus_19 = (_plus_18 + _property_9);
                            annotationImports = _plus_19;
                            this.existsImportCascade = true;
                          }
                        } else {
                          CreateDAO _createdao_6 = modelCast.getCreatedao();
                          Entity _firstEntity_3 = _createdao_6.getFirstEntity();
                          String _name_12 = _firstEntity_3.getName();
                          Type _type_5 = a.getType();
                          String _name_13 = _type_5.getName();
                          boolean _equals_6 = Objects.equal(_name_12, _name_13);
                          if (_equals_6) {
                            boolean _not_10 = (!this.existsImportOneToOne);
                            if (_not_10) {
                              CharSequence _importOneToOne_5 = this.importOneToOne();
                              String _plus_20 = (annotationImports + _importOneToOne_5);
                              String _property_10 = System.getProperty("line.separator");
                              String _plus_21 = (_plus_20 + _property_10);
                              annotationImports = _plus_21;
                              this.existsImportOneToOne = true;
                            }
                            boolean _not_11 = (!this.existsImportPrimaryKeyJoinColumn);
                            if (_not_11) {
                              CharSequence _importPrimaryKeyJoinColumn_2 = this.importPrimaryKeyJoinColumn();
                              String _plus_22 = (annotationImports + _importPrimaryKeyJoinColumn_2);
                              String _property_11 = System.getProperty("line.separator");
                              String _plus_23 = (_plus_22 + _property_11);
                              annotationImports = _plus_23;
                              this.existsImportPrimaryKeyJoinColumn = true;
                            }
                          } else {
                            CreateDAO _createdao_7 = modelCast.getCreatedao();
                            EList<Entity> _entities_1 = _createdao_7.getEntities();
                            for (final Entity ent_1 : _entities_1) {
                              String _name_14 = ent_1.getName();
                              String _name_15 = entidade.getName();
                              boolean _equals_7 = Objects.equal(_name_14, _name_15);
                              if (_equals_7) {
                                boolean _not_12 = (!this.existsImportOneToOne);
                                if (_not_12) {
                                  CharSequence _importOneToOne_6 = this.importOneToOne();
                                  String _plus_24 = (annotationImports + _importOneToOne_6);
                                  String _property_12 = System.getProperty("line.separator");
                                  String _plus_25 = (_plus_24 + _property_12);
                                  annotationImports = _plus_25;
                                  this.existsImportOneToOne = true;
                                }
                                boolean _not_13 = (!this.existsImportCascade);
                                if (_not_13) {
                                  CharSequence _importCascade_3 = this.importCascade();
                                  String _plus_26 = (annotationImports + _importCascade_3);
                                  String _property_13 = System.getProperty("line.separator");
                                  String _plus_27 = (_plus_26 + _property_13);
                                  annotationImports = _plus_27;
                                  this.existsImportCascade = true;
                                }
                              } else {
                                String _name_16 = ent_1.getName();
                                Type _type_6 = a.getType();
                                String _name_17 = _type_6.getName();
                                boolean _equals_8 = Objects.equal(_name_16, _name_17);
                                if (_equals_8) {
                                  boolean _not_14 = (!this.existsImportOneToOne);
                                  if (_not_14) {
                                    CharSequence _importOneToOne_7 = this.importOneToOne();
                                    String _plus_28 = (annotationImports + _importOneToOne_7);
                                    String _property_14 = System.getProperty("line.separator");
                                    String _plus_29 = (_plus_28 + _property_14);
                                    annotationImports = _plus_29;
                                    this.existsImportOneToOne = true;
                                  }
                                  boolean _not_15 = (!this.existsImportPrimaryKeyJoinColumn);
                                  if (_not_15) {
                                    CharSequence _importPrimaryKeyJoinColumn_3 = this.importPrimaryKeyJoinColumn();
                                    String _plus_30 = (annotationImports + _importPrimaryKeyJoinColumn_3);
                                    String _property_15 = System.getProperty("line.separator");
                                    String _plus_31 = (_plus_30 + _property_15);
                                    annotationImports = _plus_31;
                                    this.existsImportPrimaryKeyJoinColumn = true;
                                  }
                                }
                              }
                            }
                          }
                        }
                      } else {
                        boolean _not_16 = (!this.existsImportOneToOne);
                        if (_not_16) {
                          CharSequence _importOneToOne_8 = this.importOneToOne();
                          String _plus_32 = (annotationImports + _importOneToOne_8);
                          String _property_16 = System.getProperty("line.separator");
                          String _plus_33 = (_plus_32 + _property_16);
                          annotationImports = _plus_33;
                          this.existsImportOneToOne = true;
                        }
                      }
                    }
                  }
                }
                boolean _isMany = e.isMany();
                if (_isMany) {
                  boolean _not_17 = (!this.existsImportManyToOne);
                  if (_not_17) {
                    CharSequence _importManyToOne = this.importManyToOne();
                    String _plus_34 = (annotationImports + _importManyToOne);
                    String _property_17 = System.getProperty("line.separator");
                    String _plus_35 = (_plus_34 + _property_17);
                    annotationImports = _plus_35;
                    this.existsImportManyToOne = true;
                    Type _type_7 = a.getType();
                    EList<Attribute> _attributes_1 = ((Entity) _type_7).getAttributes();
                    for (final Attribute ent_2 : _attributes_1) {
                      Flags _flags = ent_2.getFlags();
                      boolean _notEquals_2 = (!Objects.equal(_flags, null));
                      if (_notEquals_2) {
                        Flags _flags_1 = ent_2.getFlags();
                        boolean _isId = _flags_1.isId();
                        if (_isId) {
                          boolean _not_18 = (!this.existsImportJoinColumn);
                          if (_not_18) {
                            CharSequence _importJoinColumn = this.importJoinColumn();
                            String _plus_36 = (annotationImports + _importJoinColumn);
                            String _property_18 = System.getProperty("line.separator");
                            String _plus_37 = (_plus_36 + _property_18);
                            annotationImports = _plus_37;
                            this.existsImportJoinColumn = true;
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        } else {
          boolean _isMany_1 = a.isMany();
          if (_isMany_1) {
            EObject _eContainer_6 = a.eContainer();
            if ((_eContainer_6 instanceof Entity)) {
              EObject _eContainer_7 = a.eContainer();
              Entity entidade_1 = ((Entity) _eContainer_7);
              Type _type_8 = a.getType();
              EList<Attribute> _attributes_2 = ((Entity) _type_8).getAttributes();
              for (final Attribute e_1 : _attributes_2) {
                Type _type_9 = e_1.getType();
                String _name_18 = _type_9.getName();
                String _name_19 = entidade_1.getName();
                boolean _equals_9 = Objects.equal(_name_18, _name_19);
                if (_equals_9) {
                  boolean _isOne_2 = e_1.isOne();
                  if (_isOne_2) {
                    boolean _not_19 = (!this.existsImportOneToMany);
                    if (_not_19) {
                      CharSequence _importOneToMany = this.importOneToMany();
                      String _plus_38 = (annotationImports + _importOneToMany);
                      String _property_19 = System.getProperty("line.separator");
                      String _plus_39 = (_plus_38 + _property_19);
                      annotationImports = _plus_39;
                      this.existsImportOneToMany = true;
                    }
                  }
                  boolean _isMany_2 = e_1.isMany();
                  if (_isMany_2) {
                    EObject _eContainer_8 = entidade_1.eContainer();
                    if ((_eContainer_8 instanceof Layer)) {
                      EObject _eContainer_9 = entidade_1.eContainer();
                      Layer layerCast_1 = ((Layer) _eContainer_9);
                      CreateDAO _createdao_8 = layerCast_1.getCreatedao();
                      boolean _notEquals_3 = (!Objects.equal(_createdao_8, null));
                      if (_notEquals_3) {
                        CreateDAO _createdao_9 = layerCast_1.getCreatedao();
                        Entity _firstEntity_4 = _createdao_9.getFirstEntity();
                        String _name_20 = _firstEntity_4.getName();
                        String _name_21 = entidade_1.getName();
                        boolean _equals_10 = Objects.equal(_name_20, _name_21);
                        if (_equals_10) {
                          boolean _not_20 = (!this.existsImportManyToMany);
                          if (_not_20) {
                            CharSequence _importManyToMany = this.importManyToMany();
                            String _plus_40 = (annotationImports + _importManyToMany);
                            String _property_20 = System.getProperty("line.separator");
                            String _plus_41 = (_plus_40 + _property_20);
                            annotationImports = _plus_41;
                            this.existsImportManyToMany = true;
                          }
                          boolean _not_21 = (!this.existsImportJoinTable);
                          if (_not_21) {
                            CharSequence _importJoinTable = this.importJoinTable();
                            String _plus_42 = (annotationImports + _importJoinTable);
                            String _property_21 = System.getProperty("line.separator");
                            String _plus_43 = (_plus_42 + _property_21);
                            annotationImports = _plus_43;
                            this.existsImportJoinTable = true;
                          }
                          boolean _not_22 = (!this.existsImportJoinColumn);
                          if (_not_22) {
                            CharSequence _importJoinColumn_1 = this.importJoinColumn();
                            String _plus_44 = (annotationImports + _importJoinColumn_1);
                            String _property_22 = System.getProperty("line.separator");
                            String _plus_45 = (_plus_44 + _property_22);
                            annotationImports = _plus_45;
                            this.existsImportJoinColumn = true;
                          }
                          boolean _not_23 = (!this.existsImportCascade);
                          if (_not_23) {
                            CharSequence _importCascade_4 = this.importCascade();
                            String _plus_46 = (annotationImports + _importCascade_4);
                            String _property_23 = System.getProperty("line.separator");
                            String _plus_47 = (_plus_46 + _property_23);
                            annotationImports = _plus_47;
                            this.existsImportCascade = true;
                          }
                        } else {
                          CreateDAO _createdao_10 = layerCast_1.getCreatedao();
                          Entity _firstEntity_5 = _createdao_10.getFirstEntity();
                          String _name_22 = _firstEntity_5.getName();
                          Type _type_10 = a.getType();
                          String _name_23 = _type_10.getName();
                          boolean _equals_11 = Objects.equal(_name_22, _name_23);
                          if (_equals_11) {
                            boolean _not_24 = (!this.existsImportManyToMany);
                            if (_not_24) {
                              CharSequence _importManyToMany_1 = this.importManyToMany();
                              String _plus_48 = (annotationImports + _importManyToMany_1);
                              String _property_24 = System.getProperty("line.separator");
                              String _plus_49 = (_plus_48 + _property_24);
                              annotationImports = _plus_49;
                              this.existsImportManyToMany = true;
                            }
                          } else {
                            CreateDAO _createdao_11 = layerCast_1.getCreatedao();
                            EList<Entity> _entities_2 = _createdao_11.getEntities();
                            for (final Entity ent_3 : _entities_2) {
                              String _name_24 = ent_3.getName();
                              String _name_25 = entidade_1.getName();
                              boolean _equals_12 = Objects.equal(_name_24, _name_25);
                              if (_equals_12) {
                                boolean _not_25 = (!this.existsImportManyToMany);
                                if (_not_25) {
                                  CharSequence _importManyToMany_2 = this.importManyToMany();
                                  String _plus_50 = (annotationImports + _importManyToMany_2);
                                  String _property_25 = System.getProperty("line.separator");
                                  String _plus_51 = (_plus_50 + _property_25);
                                  annotationImports = _plus_51;
                                  this.existsImportManyToMany = true;
                                }
                                boolean _not_26 = (!this.existsImportJoinTable);
                                if (_not_26) {
                                  CharSequence _importJoinTable_1 = this.importJoinTable();
                                  String _plus_52 = (annotationImports + _importJoinTable_1);
                                  String _property_26 = System.getProperty("line.separator");
                                  String _plus_53 = (_plus_52 + _property_26);
                                  annotationImports = _plus_53;
                                  this.existsImportJoinTable = true;
                                }
                                boolean _not_27 = (!this.existsImportJoinColumn);
                                if (_not_27) {
                                  CharSequence _importJoinColumn_2 = this.importJoinColumn();
                                  String _plus_54 = (annotationImports + _importJoinColumn_2);
                                  String _property_27 = System.getProperty("line.separator");
                                  String _plus_55 = (_plus_54 + _property_27);
                                  annotationImports = _plus_55;
                                  this.existsImportJoinColumn = true;
                                }
                                boolean _not_28 = (!this.existsImportCascade);
                                if (_not_28) {
                                  CharSequence _importCascade_5 = this.importCascade();
                                  String _plus_56 = (annotationImports + _importCascade_5);
                                  String _property_28 = System.getProperty("line.separator");
                                  String _plus_57 = (_plus_56 + _property_28);
                                  annotationImports = _plus_57;
                                  this.existsImportCascade = true;
                                }
                              } else {
                                String _name_26 = ent_3.getName();
                                Type _type_11 = a.getType();
                                String _name_27 = _type_11.getName();
                                boolean _equals_13 = Objects.equal(_name_26, _name_27);
                                if (_equals_13) {
                                  boolean _not_29 = (!this.existsImportManyToMany);
                                  if (_not_29) {
                                    CharSequence _importManyToMany_3 = this.importManyToMany();
                                    String _plus_58 = (annotationImports + _importManyToMany_3);
                                    String _property_29 = System.getProperty("line.separator");
                                    String _plus_59 = (_plus_58 + _property_29);
                                    annotationImports = _plus_59;
                                    this.existsImportManyToMany = true;
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    } else {
                      EObject _eContainer_10 = entidade_1.eContainer();
                      if ((_eContainer_10 instanceof Model)) {
                        EObject _eContainer_11 = entidade_1.eContainer();
                        Model modelCast_1 = ((Model) _eContainer_11);
                        CreateDAO _createdao_12 = modelCast_1.getCreatedao();
                        boolean _notEquals_4 = (!Objects.equal(_createdao_12, null));
                        if (_notEquals_4) {
                          CreateDAO _createdao_13 = modelCast_1.getCreatedao();
                          Entity _firstEntity_6 = _createdao_13.getFirstEntity();
                          String _name_28 = _firstEntity_6.getName();
                          String _name_29 = entidade_1.getName();
                          boolean _equals_14 = Objects.equal(_name_28, _name_29);
                          if (_equals_14) {
                            boolean _not_30 = (!this.existsImportManyToMany);
                            if (_not_30) {
                              CharSequence _importManyToMany_4 = this.importManyToMany();
                              String _plus_60 = (annotationImports + _importManyToMany_4);
                              String _property_30 = System.getProperty("line.separator");
                              String _plus_61 = (_plus_60 + _property_30);
                              annotationImports = _plus_61;
                              this.existsImportManyToMany = true;
                            }
                            boolean _not_31 = (!this.existsImportJoinTable);
                            if (_not_31) {
                              CharSequence _importJoinTable_2 = this.importJoinTable();
                              String _plus_62 = (annotationImports + _importJoinTable_2);
                              String _property_31 = System.getProperty("line.separator");
                              String _plus_63 = (_plus_62 + _property_31);
                              annotationImports = _plus_63;
                              this.existsImportJoinTable = true;
                            }
                            boolean _not_32 = (!this.existsImportJoinColumn);
                            if (_not_32) {
                              CharSequence _importJoinColumn_3 = this.importJoinColumn();
                              String _plus_64 = (annotationImports + _importJoinColumn_3);
                              String _property_32 = System.getProperty("line.separator");
                              String _plus_65 = (_plus_64 + _property_32);
                              annotationImports = _plus_65;
                              this.existsImportJoinColumn = true;
                            }
                            boolean _not_33 = (!this.existsImportCascade);
                            if (_not_33) {
                              CharSequence _importCascade_6 = this.importCascade();
                              String _plus_66 = (annotationImports + _importCascade_6);
                              String _property_33 = System.getProperty("line.separator");
                              String _plus_67 = (_plus_66 + _property_33);
                              annotationImports = _plus_67;
                              this.existsImportCascade = true;
                            }
                          } else {
                            CreateDAO _createdao_14 = modelCast_1.getCreatedao();
                            Entity _firstEntity_7 = _createdao_14.getFirstEntity();
                            String _name_30 = _firstEntity_7.getName();
                            Type _type_12 = a.getType();
                            String _name_31 = _type_12.getName();
                            boolean _equals_15 = Objects.equal(_name_30, _name_31);
                            if (_equals_15) {
                              boolean _not_34 = (!this.existsImportManyToMany);
                              if (_not_34) {
                                CharSequence _importManyToMany_5 = this.importManyToMany();
                                String _plus_68 = (annotationImports + _importManyToMany_5);
                                String _property_34 = System.getProperty("line.separator");
                                String _plus_69 = (_plus_68 + _property_34);
                                annotationImports = _plus_69;
                                this.existsImportManyToMany = true;
                              }
                            } else {
                              CreateDAO _createdao_15 = modelCast_1.getCreatedao();
                              EList<Entity> _entities_3 = _createdao_15.getEntities();
                              for (final Entity ent_4 : _entities_3) {
                                String _name_32 = ent_4.getName();
                                String _name_33 = entidade_1.getName();
                                boolean _equals_16 = Objects.equal(_name_32, _name_33);
                                if (_equals_16) {
                                  boolean _not_35 = (!this.existsImportManyToMany);
                                  if (_not_35) {
                                    CharSequence _importManyToMany_6 = this.importManyToMany();
                                    String _plus_70 = (annotationImports + _importManyToMany_6);
                                    String _property_35 = System.getProperty("line.separator");
                                    String _plus_71 = (_plus_70 + _property_35);
                                    annotationImports = _plus_71;
                                    this.existsImportManyToMany = true;
                                  }
                                  boolean _not_36 = (!this.existsImportJoinTable);
                                  if (_not_36) {
                                    CharSequence _importJoinTable_3 = this.importJoinTable();
                                    String _plus_72 = (annotationImports + _importJoinTable_3);
                                    String _property_36 = System.getProperty("line.separator");
                                    String _plus_73 = (_plus_72 + _property_36);
                                    annotationImports = _plus_73;
                                    this.existsImportJoinTable = true;
                                  }
                                  boolean _not_37 = (!this.existsImportJoinColumn);
                                  if (_not_37) {
                                    CharSequence _importJoinColumn_4 = this.importJoinColumn();
                                    String _plus_74 = (annotationImports + _importJoinColumn_4);
                                    String _property_37 = System.getProperty("line.separator");
                                    String _plus_75 = (_plus_74 + _property_37);
                                    annotationImports = _plus_75;
                                    this.existsImportJoinColumn = true;
                                  }
                                  boolean _not_38 = (!this.existsImportCascade);
                                  if (_not_38) {
                                    CharSequence _importCascade_7 = this.importCascade();
                                    String _plus_76 = (annotationImports + _importCascade_7);
                                    String _property_38 = System.getProperty("line.separator");
                                    String _plus_77 = (_plus_76 + _property_38);
                                    annotationImports = _plus_77;
                                    this.existsImportCascade = true;
                                  }
                                } else {
                                  String _name_34 = ent_4.getName();
                                  Type _type_13 = a.getType();
                                  String _name_35 = _type_13.getName();
                                  boolean _equals_17 = Objects.equal(_name_34, _name_35);
                                  if (_equals_17) {
                                    boolean _not_39 = (!this.existsImportManyToMany);
                                    if (_not_39) {
                                      CharSequence _importManyToMany_7 = this.importManyToMany();
                                      String _plus_78 = (annotationImports + _importManyToMany_7);
                                      String _property_39 = System.getProperty("line.separator");
                                      String _plus_79 = (_plus_78 + _property_39);
                                      annotationImports = _plus_79;
                                      this.existsImportManyToMany = true;
                                    }
                                  }
                                }
                              }
                            }
                          }
                        } else {
                          boolean _not_40 = (!this.existsImportManyToMany);
                          if (_not_40) {
                            CharSequence _importManyToMany_8 = this.importManyToMany();
                            String _plus_80 = (annotationImports + _importManyToMany_8);
                            String _property_40 = System.getProperty("line.separator");
                            String _plus_81 = (_plus_80 + _property_40);
                            annotationImports = _plus_81;
                            this.existsImportManyToMany = true;
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
      _xblockexpression = (annotationImports);
    }
    return _xblockexpression;
  }
  
  public String verifyAnnotations(final Object o) {
    String _xblockexpression = null;
    {
      String annotationMarks = "";
      boolean _matched = false;
      if (!_matched) {
        if (o instanceof Entity) {
          final Entity _entity = (Entity)o;
          _matched=true;
          String _entityAnnotations = this.entityAnnotations(((Entity) _entity));
          annotationMarks = _entityAnnotations;
        }
      }
      if (!_matched) {
        if (o instanceof Attribute) {
          final Attribute _attribute = (Attribute)o;
          _matched=true;
          Type _type = _attribute.getType();
          if ((_type instanceof TypeDef)) {
            String _flagAndColumnAnnotations = this.flagAndColumnAnnotations(((Attribute) _attribute));
            annotationMarks = _flagAndColumnAnnotations;
          } else {
            Type _type_1 = _attribute.getType();
            if ((_type_1 instanceof Entity)) {
              String _relationshipAnnotations = this.relationshipAnnotations(((Attribute) _attribute));
              annotationMarks = _relationshipAnnotations;
            }
          }
        }
      }
      _xblockexpression = (annotationMarks);
    }
    return _xblockexpression;
  }
  
  public String entityAnnotations(final Entity e) {
    String _xblockexpression = null;
    {
      CharSequence _entity = this.entity();
      String _property = System.getProperty("line.separator");
      String _plus = (_entity + _property);
      CharSequence _table = this.table(e);
      String _plus_1 = (_plus + _table);
      String _property_1 = System.getProperty("line.separator");
      String annotationMarks = (_plus_1 + _property_1);
      Entity _superEntity = e.getSuperEntity();
      boolean _notEquals = (!Objects.equal(_superEntity, null));
      if (_notEquals) {
        Entity _superEntity_1 = e.getSuperEntity();
        EList<Attribute> _attributes = _superEntity_1.getAttributes();
        for (final Attribute a : _attributes) {
          Flags _flags = a.getFlags();
          boolean _notEquals_1 = (!Objects.equal(_flags, null));
          if (_notEquals_1) {
            Flags _flags_1 = a.getFlags();
            boolean _isId = _flags_1.isId();
            if (_isId) {
              CharSequence _primaryKeyJoinColumn = this.primaryKeyJoinColumn(a);
              String _plus_2 = (annotationMarks + _primaryKeyJoinColumn);
              String _property_2 = System.getProperty("line.separator");
              String _plus_3 = (_plus_2 + _property_2);
              annotationMarks = _plus_3;
            }
          }
        }
      }
      EObject _eContainer = e.eContainer();
      if ((_eContainer instanceof Model)) {
        EObject _eContainer_1 = e.eContainer();
        EList<Type> otherEntities = ((Model) _eContainer_1).getTypes();
        boolean pass = false;
        for (final Type ent : otherEntities) {
          if ((ent instanceof Entity)) {
            boolean _and = false;
            Entity _superEntity_2 = ((Entity) ent).getSuperEntity();
            String _name = _superEntity_2.getName();
            String _name_1 = e.getName();
            boolean _equals = Objects.equal(_name, _name_1);
            if (!_equals) {
              _and = false;
            } else {
              boolean _not = (!pass);
              _and = (_equals && _not);
            }
            if (_and) {
              CharSequence _inheritance = this.inheritance();
              String _plus_4 = (annotationMarks + _inheritance);
              String _property_3 = System.getProperty("line.separator");
              String _plus_5 = (_plus_4 + _property_3);
              annotationMarks = _plus_5;
              pass = true;
            }
          }
        }
      } else {
        EObject _eContainer_2 = e.eContainer();
        if ((_eContainer_2 instanceof Layer)) {
          EObject _eContainer_3 = e.eContainer();
          EList<Type> otherEntities_1 = ((Layer) _eContainer_3).getTypes();
          boolean pass_1 = false;
          for (final Type ent_1 : otherEntities_1) {
            if ((ent_1 instanceof Entity)) {
              Entity entCast = ((Entity) ent_1);
              Entity _superEntity_3 = entCast.getSuperEntity();
              boolean _notEquals_2 = (!Objects.equal(_superEntity_3, null));
              if (_notEquals_2) {
                boolean _and_1 = false;
                Entity _superEntity_4 = entCast.getSuperEntity();
                String _name_2 = _superEntity_4.getName();
                String _name_3 = e.getName();
                boolean _equals_1 = Objects.equal(_name_2, _name_3);
                if (!_equals_1) {
                  _and_1 = false;
                } else {
                  boolean _not_1 = (!pass_1);
                  _and_1 = (_equals_1 && _not_1);
                }
                if (_and_1) {
                  CharSequence _inheritance_1 = this.inheritance();
                  String _plus_6 = (annotationMarks + _inheritance_1);
                  String _property_4 = System.getProperty("line.separator");
                  String _plus_7 = (_plus_6 + _property_4);
                  annotationMarks = _plus_7;
                  pass_1 = true;
                }
              }
            }
          }
        }
      }
      _xblockexpression = (annotationMarks);
    }
    return _xblockexpression;
  }
  
  public String flagAndColumnAnnotations(final Attribute a) {
    String _xblockexpression = null;
    {
      String annotationMarks = "";
      Type _type = a.getType();
      TypeDef aTypeDef = ((TypeDef) _type);
      Flags _flags = a.getFlags();
      boolean _notEquals = (!Objects.equal(_flags, null));
      if (_notEquals) {
        Flags _flags_1 = a.getFlags();
        boolean _isId = _flags_1.isId();
        if (_isId) {
          CharSequence _id = this.id();
          String _plus = (annotationMarks + _id);
          String _property = System.getProperty("line.separator");
          String _plus_1 = (_plus + _property);
          annotationMarks = _plus_1;
          Flags _flags_2 = a.getFlags();
          boolean _isAutoid = _flags_2.isAutoid();
          if (_isAutoid) {
            CharSequence _generatedValue = this.generatedValue();
            String _plus_2 = (annotationMarks + _generatedValue);
            String _property_1 = System.getProperty("line.separator");
            String _plus_3 = (_plus_2 + _property_1);
            annotationMarks = _plus_3;
          }
        }
      }
      CharSequence _column = this.column(a);
      String _plus_4 = (annotationMarks + _column);
      String _property_2 = System.getProperty("line.separator");
      String _plus_5 = (_plus_4 + _property_2);
      annotationMarks = _plus_5;
      String _mappedType = aTypeDef.getMappedType();
      boolean _notEquals_1 = (!Objects.equal(_mappedType, null));
      if (_notEquals_1) {
        String _mappedType_1 = aTypeDef.getMappedType();
        boolean _equals = Objects.equal(_mappedType_1, "java.util.Date");
        if (_equals) {
          CharSequence _temporal = this.temporal();
          String _plus_6 = (annotationMarks + _temporal);
          String _property_3 = System.getProperty("line.separator");
          String _plus_7 = (_plus_6 + _property_3);
          annotationMarks = _plus_7;
        }
      }
      _xblockexpression = (annotationMarks);
    }
    return _xblockexpression;
  }
  
  public String relationshipAnnotations(final Attribute a) {
    String _xblockexpression = null;
    {
      String annotationMarks = "";
      Type _type = a.getType();
      if ((_type instanceof Entity)) {
        boolean _isOne = a.isOne();
        if (_isOne) {
          EObject _eContainer = a.eContainer();
          if ((_eContainer instanceof Entity)) {
            EObject _eContainer_1 = a.eContainer();
            Entity entidade = ((Entity) _eContainer_1);
            Type _type_1 = a.getType();
            EList<Attribute> _attributes = ((Entity) _type_1).getAttributes();
            for (final Attribute e : _attributes) {
              Type _type_2 = e.getType();
              String _name = _type_2.getName();
              String _name_1 = entidade.getName();
              boolean _equals = Objects.equal(_name, _name_1);
              if (_equals) {
                boolean _isOne_1 = e.isOne();
                if (_isOne_1) {
                  EObject _eContainer_2 = entidade.eContainer();
                  if ((_eContainer_2 instanceof Layer)) {
                    EObject _eContainer_3 = entidade.eContainer();
                    Layer layerCast = ((Layer) _eContainer_3);
                    CreateDAO _createdao = layerCast.getCreatedao();
                    boolean _notEquals = (!Objects.equal(_createdao, null));
                    if (_notEquals) {
                      CreateDAO _createdao_1 = layerCast.getCreatedao();
                      Entity _firstEntity = _createdao_1.getFirstEntity();
                      String _name_2 = _firstEntity.getName();
                      String _name_3 = entidade.getName();
                      boolean _equals_1 = Objects.equal(_name_2, _name_3);
                      if (_equals_1) {
                        CharSequence _oneToOne = this.oneToOne(e);
                        String _plus = (annotationMarks + _oneToOne);
                        annotationMarks = _plus;
                      } else {
                        CreateDAO _createdao_2 = layerCast.getCreatedao();
                        Entity _firstEntity_1 = _createdao_2.getFirstEntity();
                        String _name_4 = _firstEntity_1.getName();
                        Type _type_3 = a.getType();
                        String _name_5 = _type_3.getName();
                        boolean _equals_2 = Objects.equal(_name_4, _name_5);
                        if (_equals_2) {
                          CharSequence _oneToOne_1 = this.oneToOne();
                          String _plus_1 = (annotationMarks + _oneToOne_1);
                          String _property = System.getProperty("line.separator");
                          String _plus_2 = (_plus_1 + _property);
                          CharSequence _primaryKeyJoinColumn = this.primaryKeyJoinColumn();
                          String _plus_3 = (_plus_2 + _primaryKeyJoinColumn);
                          annotationMarks = _plus_3;
                        } else {
                          boolean pass = false;
                          CreateDAO _createdao_3 = layerCast.getCreatedao();
                          EList<Entity> _entities = _createdao_3.getEntities();
                          for (final Entity ent : _entities) {
                            boolean _not = (!pass);
                            if (_not) {
                              String _name_6 = ent.getName();
                              String _name_7 = entidade.getName();
                              boolean _equals_3 = Objects.equal(_name_6, _name_7);
                              if (_equals_3) {
                                CharSequence _oneToOne_2 = this.oneToOne(e);
                                String _plus_4 = (annotationMarks + _oneToOne_2);
                                annotationMarks = _plus_4;
                                pass = true;
                              } else {
                                String _name_8 = ent.getName();
                                Type _type_4 = a.getType();
                                String _name_9 = _type_4.getName();
                                boolean _equals_4 = Objects.equal(_name_8, _name_9);
                                if (_equals_4) {
                                  CharSequence _oneToOne_3 = this.oneToOne();
                                  String _plus_5 = (annotationMarks + _oneToOne_3);
                                  String _property_1 = System.getProperty("line.separator");
                                  String _plus_6 = (_plus_5 + _property_1);
                                  CharSequence _primaryKeyJoinColumn_1 = this.primaryKeyJoinColumn();
                                  String _plus_7 = (_plus_6 + _primaryKeyJoinColumn_1);
                                  annotationMarks = _plus_7;
                                  pass = true;
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  } else {
                    EObject _eContainer_4 = entidade.eContainer();
                    if ((_eContainer_4 instanceof Model)) {
                      EObject _eContainer_5 = entidade.eContainer();
                      Model modelCast = ((Model) _eContainer_5);
                      CreateDAO _createdao_4 = modelCast.getCreatedao();
                      boolean _notEquals_1 = (!Objects.equal(_createdao_4, null));
                      if (_notEquals_1) {
                        CreateDAO _createdao_5 = modelCast.getCreatedao();
                        Entity _firstEntity_2 = _createdao_5.getFirstEntity();
                        String _name_10 = _firstEntity_2.getName();
                        String _name_11 = entidade.getName();
                        boolean _equals_5 = Objects.equal(_name_10, _name_11);
                        if (_equals_5) {
                          CharSequence _oneToOne_4 = this.oneToOne(e);
                          String _plus_8 = (annotationMarks + _oneToOne_4);
                          annotationMarks = _plus_8;
                        } else {
                          CreateDAO _createdao_6 = modelCast.getCreatedao();
                          Entity _firstEntity_3 = _createdao_6.getFirstEntity();
                          String _name_12 = _firstEntity_3.getName();
                          Type _type_5 = a.getType();
                          String _name_13 = _type_5.getName();
                          boolean _equals_6 = Objects.equal(_name_12, _name_13);
                          if (_equals_6) {
                            CharSequence _oneToOne_5 = this.oneToOne();
                            String _plus_9 = (annotationMarks + _oneToOne_5);
                            String _property_2 = System.getProperty("line.separator");
                            String _plus_10 = (_plus_9 + _property_2);
                            CharSequence _primaryKeyJoinColumn_2 = this.primaryKeyJoinColumn();
                            String _plus_11 = (_plus_10 + _primaryKeyJoinColumn_2);
                            annotationMarks = _plus_11;
                          } else {
                            boolean pass_1 = false;
                            CreateDAO _createdao_7 = modelCast.getCreatedao();
                            EList<Entity> _entities_1 = _createdao_7.getEntities();
                            for (final Entity ent_1 : _entities_1) {
                              boolean _not_1 = (!pass_1);
                              if (_not_1) {
                                String _name_14 = ent_1.getName();
                                String _name_15 = entidade.getName();
                                boolean _equals_7 = Objects.equal(_name_14, _name_15);
                                if (_equals_7) {
                                  CharSequence _oneToOne_6 = this.oneToOne(e);
                                  String _plus_12 = (annotationMarks + _oneToOne_6);
                                  annotationMarks = _plus_12;
                                  pass_1 = true;
                                } else {
                                  String _name_16 = ent_1.getName();
                                  Type _type_6 = a.getType();
                                  String _name_17 = _type_6.getName();
                                  boolean _equals_8 = Objects.equal(_name_16, _name_17);
                                  if (_equals_8) {
                                    CharSequence _oneToOne_7 = this.oneToOne();
                                    String _plus_13 = (annotationMarks + _oneToOne_7);
                                    String _property_3 = System.getProperty("line.separator");
                                    String _plus_14 = (_plus_13 + _property_3);
                                    CharSequence _primaryKeyJoinColumn_3 = this.primaryKeyJoinColumn();
                                    String _plus_15 = (_plus_14 + _primaryKeyJoinColumn_3);
                                    annotationMarks = _plus_15;
                                    pass_1 = true;
                                  }
                                }
                              }
                            }
                          }
                        }
                      } else {
                        StringConcatenation _builder = new StringConcatenation();
                        CharSequence _oneToOne_8 = this.oneToOne();
                        _builder.append(_oneToOne_8, "");
                        annotationMarks = _builder.toString();
                      }
                    }
                  }
                }
                boolean _isMany = e.isMany();
                if (_isMany) {
                  CharSequence _manyToOne = this.manyToOne();
                  String _property_4 = System.getProperty("line.separator");
                  String _plus_16 = (_manyToOne + _property_4);
                  annotationMarks = _plus_16;
                  Type _type_7 = a.getType();
                  EList<Attribute> _attributes_1 = ((Entity) _type_7).getAttributes();
                  for (final Attribute ent_2 : _attributes_1) {
                    Flags _flags = ent_2.getFlags();
                    boolean _notEquals_2 = (!Objects.equal(_flags, null));
                    if (_notEquals_2) {
                      Flags _flags_1 = ent_2.getFlags();
                      boolean _isId = _flags_1.isId();
                      if (_isId) {
                        CharSequence _joinColumn = this.joinColumn(ent_2);
                        String _plus_17 = (annotationMarks + _joinColumn);
                        annotationMarks = _plus_17;
                      }
                    }
                  }
                }
              }
            }
          }
        } else {
          boolean _isMany_1 = a.isMany();
          if (_isMany_1) {
            EObject _eContainer_6 = a.eContainer();
            if ((_eContainer_6 instanceof Entity)) {
              EObject _eContainer_7 = a.eContainer();
              Entity entidade_1 = ((Entity) _eContainer_7);
              Type _type_8 = a.getType();
              EList<Attribute> _attributes_2 = ((Entity) _type_8).getAttributes();
              for (final Attribute e_1 : _attributes_2) {
                Type _type_9 = e_1.getType();
                String _name_18 = _type_9.getName();
                String _name_19 = entidade_1.getName();
                boolean _equals_9 = Objects.equal(_name_18, _name_19);
                if (_equals_9) {
                  boolean _isOne_2 = e_1.isOne();
                  if (_isOne_2) {
                    StringConcatenation _builder_1 = new StringConcatenation();
                    CharSequence _oneToMany = this.oneToMany(e_1);
                    _builder_1.append(_oneToMany, "");
                    annotationMarks = _builder_1.toString();
                  }
                  boolean _isMany_2 = e_1.isMany();
                  if (_isMany_2) {
                    EObject _eContainer_8 = entidade_1.eContainer();
                    if ((_eContainer_8 instanceof Layer)) {
                      EObject _eContainer_9 = entidade_1.eContainer();
                      Layer layerCast_1 = ((Layer) _eContainer_9);
                      CreateDAO _createdao_8 = layerCast_1.getCreatedao();
                      boolean _notEquals_3 = (!Objects.equal(_createdao_8, null));
                      if (_notEquals_3) {
                        CreateDAO _createdao_9 = layerCast_1.getCreatedao();
                        Entity _firstEntity_4 = _createdao_9.getFirstEntity();
                        String _name_20 = _firstEntity_4.getName();
                        String _name_21 = entidade_1.getName();
                        boolean _equals_10 = Objects.equal(_name_20, _name_21);
                        if (_equals_10) {
                          CharSequence _manyToMany = this.manyToMany();
                          String _plus_18 = (annotationMarks + _manyToMany);
                          String _property_5 = System.getProperty("line.separator");
                          String _plus_19 = (_plus_18 + _property_5);
                          CharSequence _joinTable = this.joinTable(e_1, a);
                          String _plus_20 = (_plus_19 + _joinTable);
                          annotationMarks = _plus_20;
                        } else {
                          CreateDAO _createdao_10 = layerCast_1.getCreatedao();
                          Entity _firstEntity_5 = _createdao_10.getFirstEntity();
                          String _name_22 = _firstEntity_5.getName();
                          Type _type_10 = a.getType();
                          String _name_23 = _type_10.getName();
                          boolean _equals_11 = Objects.equal(_name_22, _name_23);
                          if (_equals_11) {
                            CharSequence _manyToMany_1 = this.manyToMany(e_1);
                            String _plus_21 = (annotationMarks + _manyToMany_1);
                            annotationMarks = _plus_21;
                          } else {
                            boolean pass_2 = false;
                            CreateDAO _createdao_11 = layerCast_1.getCreatedao();
                            EList<Entity> _entities_2 = _createdao_11.getEntities();
                            for (final Entity ent_3 : _entities_2) {
                              boolean _not_2 = (!pass_2);
                              if (_not_2) {
                                String _name_24 = ent_3.getName();
                                String _name_25 = entidade_1.getName();
                                boolean _equals_12 = Objects.equal(_name_24, _name_25);
                                if (_equals_12) {
                                  CharSequence _manyToMany_2 = this.manyToMany();
                                  String _plus_22 = (annotationMarks + _manyToMany_2);
                                  String _property_6 = System.getProperty("line.separator");
                                  String _plus_23 = (_plus_22 + _property_6);
                                  CharSequence _joinTable_1 = this.joinTable(e_1, a);
                                  String _plus_24 = (_plus_23 + _joinTable_1);
                                  annotationMarks = _plus_24;
                                  pass_2 = true;
                                } else {
                                  String _name_26 = ent_3.getName();
                                  Type _type_11 = a.getType();
                                  String _name_27 = _type_11.getName();
                                  boolean _equals_13 = Objects.equal(_name_26, _name_27);
                                  if (_equals_13) {
                                    CharSequence _manyToMany_3 = this.manyToMany(e_1);
                                    String _plus_25 = (annotationMarks + _manyToMany_3);
                                    annotationMarks = _plus_25;
                                    pass_2 = true;
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    } else {
                      EObject _eContainer_10 = entidade_1.eContainer();
                      if ((_eContainer_10 instanceof Model)) {
                        EObject _eContainer_11 = entidade_1.eContainer();
                        Model modelCast_1 = ((Model) _eContainer_11);
                        CreateDAO _createdao_12 = modelCast_1.getCreatedao();
                        boolean _notEquals_4 = (!Objects.equal(_createdao_12, null));
                        if (_notEquals_4) {
                          CreateDAO _createdao_13 = modelCast_1.getCreatedao();
                          Entity _firstEntity_6 = _createdao_13.getFirstEntity();
                          String _name_28 = _firstEntity_6.getName();
                          String _name_29 = entidade_1.getName();
                          boolean _equals_14 = Objects.equal(_name_28, _name_29);
                          if (_equals_14) {
                            CharSequence _manyToMany_4 = this.manyToMany();
                            String _plus_26 = (annotationMarks + _manyToMany_4);
                            String _property_7 = System.getProperty("line.separator");
                            String _plus_27 = (_plus_26 + _property_7);
                            CharSequence _joinTable_2 = this.joinTable(e_1, a);
                            String _plus_28 = (_plus_27 + _joinTable_2);
                            annotationMarks = _plus_28;
                          } else {
                            CreateDAO _createdao_14 = modelCast_1.getCreatedao();
                            Entity _firstEntity_7 = _createdao_14.getFirstEntity();
                            String _name_30 = _firstEntity_7.getName();
                            Type _type_12 = a.getType();
                            String _name_31 = _type_12.getName();
                            boolean _equals_15 = Objects.equal(_name_30, _name_31);
                            if (_equals_15) {
                              CharSequence _manyToMany_5 = this.manyToMany(a);
                              String _plus_29 = (annotationMarks + _manyToMany_5);
                              annotationMarks = _plus_29;
                            } else {
                              boolean pass_3 = false;
                              CreateDAO _createdao_15 = modelCast_1.getCreatedao();
                              EList<Entity> _entities_3 = _createdao_15.getEntities();
                              for (final Entity ent_4 : _entities_3) {
                                boolean _not_3 = (!pass_3);
                                if (_not_3) {
                                  String _name_32 = ent_4.getName();
                                  String _name_33 = entidade_1.getName();
                                  boolean _equals_16 = Objects.equal(_name_32, _name_33);
                                  if (_equals_16) {
                                    CharSequence _manyToMany_6 = this.manyToMany();
                                    String _plus_30 = (annotationMarks + _manyToMany_6);
                                    String _property_8 = System.getProperty("line.separator");
                                    String _plus_31 = (_plus_30 + _property_8);
                                    CharSequence _joinTable_3 = this.joinTable(e_1, a);
                                    String _plus_32 = (_plus_31 + _joinTable_3);
                                    annotationMarks = _plus_32;
                                    pass_3 = true;
                                  } else {
                                    String _name_34 = ent_4.getName();
                                    Type _type_13 = a.getType();
                                    String _name_35 = _type_13.getName();
                                    boolean _equals_17 = Objects.equal(_name_34, _name_35);
                                    if (_equals_17) {
                                      CharSequence _manyToMany_7 = this.manyToMany(a);
                                      String _plus_33 = (annotationMarks + _manyToMany_7);
                                      annotationMarks = _plus_33;
                                      pass_3 = true;
                                    }
                                  }
                                }
                              }
                            }
                          }
                        } else {
                          StringConcatenation _builder_2 = new StringConcatenation();
                          CharSequence _manyToMany_8 = this.manyToMany();
                          _builder_2.append(_manyToMany_8, "");
                          annotationMarks = _builder_2.toString();
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
      _xblockexpression = (annotationMarks);
    }
    return _xblockexpression;
  }
}
